#include <iostream>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>
#include <cstring>
#include <sys/select.h>
#include <cstdio> 
#include "common.h"

//size_t bytesRead;
struct sonar_data{
    size_t cnt;  
    int temperature;
    #ifdef SONAR_TYPE1
    double water_depth;
    #else 
    uint16_t water_depth;
    #endif 

};



class Sonar:public SensorAbstraction{
private:
    /* data */
    int fd;
    std::string dev_name;
    unsigned char dataToSend = 0x01;
    std::string sensor_data;
    int  timeoutSec = 5;
    std::unique_ptr<struct sonar_data> p_sonar_data;
public:
    Sonar(const std::string& sensor_name_,const int& run_mode_, const std::string& dev_name_);
    ~Sonar();
    char buffer[256];
    int Init() override;
    int sendData() ;                     
    int readData() ;   
    int DataCollection() override;                             //传感器数据采集
    int DataProcessing() override;                             //传感器数据处理
    int DataStorage() override;                                //传感器数据储存
    int DataPrint() override;                         

};